package com.itheima.api.calendar;

import java.sql.SQLOutput;
import java.util.Calendar;
import java.util.Date;

public class CalendarDemo01 {

    public static void main(String[] args) {

        //当前系统时间
        Calendar calendar = Calendar.getInstance();

        System.out.println(calendar.get(Calendar.YEAR));
        System.out.println(calendar.get(Calendar.MONTH));
        System.out.println("一个月中的第" + calendar.get(Calendar.DAY_OF_MONTH) + "天");
        System.out.println("一周中的第" + calendar.get(Calendar.DAY_OF_WEEK) + "天");
        System.out.println("-----------------------------------------------------");

        Calendar calendar1 = Calendar.getInstance();
        calendar1.add(Calendar.YEAR, 1);
        System.out.println(calendar1.get(Calendar.YEAR));
        calendar1.add(Calendar.DAY_OF_MONTH, -1);
        System.out.println(calendar1.get(Calendar.DAY_OF_MONTH));
        System.out.println("------------------------------------------------------");

        calendar.set(2017, 9, 27);
        System.out.println(calendar.get(Calendar.YEAR) + "年" + calendar.get(Calendar.MONTH) + "月" + calendar.get(Calendar.DAY_OF_MONTH) + "日");
        System.out.println(calendar.get(Calendar.MONTH));
        System.out.println("-------------------------------------------------------");

        calendar1.set(Calendar.YEAR, 2016);
        System.out.println(calendar1.get(Calendar.YEAR));
        calendar1.set(Calendar.MONTH, 9);
        System.out.println(calendar1.get(Calendar.MONTH));
        System.out.println("--------------------------------------------------------");

        calendar1.setTime(new Date());
        System.out.println(calendar1.get(Calendar.YEAR));

    }
}
